local zheji = fk.CreateSkill {
  name = "kq__zheji",
}
Fk:loadTranslationTable{
  ["kq__zheji"] = "蛰计",
  [":kq__zheji"] = "当你造成或受到伤害后，你可以将武将牌上的一个非“挑衅”技能改为“挑衅”直到本回合结束。当你失去“蛰计”时，你摸X张牌（X为你本回合发动“垫计”的次数）。",
  ["$kq__zheji1"] = "金睛审势，避水而伏，以待翻海之机！",
  ["$kq__zheji2"] = "钝阵于前，暗推蛰兵，金麒堪安于池？"
}
local spec = {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(zheji.name)
  end,
  on_use = function (self, event, target, player, data)
    local skills = table.filter(player:getSkillNameList(), function(id)
            return id~="kq__tiaoxin"
        end)
        if #skills > 0 then
          local skill = player.room:askToChoices(player, { choices = skills, min_num = 0, max_num = 1,
          skill_name = zheji.name, prompt = "将一个技能替换为“挑衅”（标）", detailed = false})[1]
          if skill then
            player.room:addTableMark(player, "kq__zheji-turn", skill)
            if player:usedSkillTimes(zheji.name, Player.HistoryTurn) == 1 then
              player.room:handleAddLoseSkills(player, "-"..skill.."|kq__tiaoxin")
            elseif player:usedSkillTimes(zheji.name, Player.HistoryTurn) == 2 then
              player.room:handleAddLoseSkills(player, "-"..skill.."|kq__tiaoxin1")
            elseif player:usedSkillTimes(zheji.name, Player.HistoryTurn) == 3 then
              player.room:handleAddLoseSkills(player, "-"..skill.."|kq__tiaoxin2")
            else
              player.room:handleAddLoseSkills(player, "-"..skill.."|kq__tiaoxin2")
            end
          end
        end
  end,
}

zheji:addEffect(fk.TurnEnd, {
  is_delay_effect = true,
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return player:getMark("kq__zheji-turn") ~= 0 
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    if player:getMark("kq__zheji-turn") ~= 0 then
      player.room:handleAddLoseSkills(player, table.concat(player:getMark("kq__zheji-turn"), "|"))
    end
    for _, p in ipairs(player:getSkillNameList()) do
      if p == "kq__tiaoxin" or p == "kq__tiaoxin1" or p == "kq__tiaoxin2" or p == "kq__tiaoxin3"then
         player.room:handleAddLoseSkills(player, "-"..p)
      end
    end
  end,
})


zheji:addLoseEffect(function (self, player, is_death)
  player:drawCards(player:usedSkillTimes(zheji.name, Player.HistoryTurn),zheji.name)
end)

zheji:addEffect(fk.Damage, spec)
zheji:addEffect(fk.Damaged, spec)
return zheji